home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / pxewin.zip / PXEOBJ.HPP < prev    next >
C/C++ Source or Header  |  1992-02-10  |  6KB  |  194 lines

  1. // PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
  2.  
  3. // PXEOBJ.HPP //
  4.  
  5. // Contents ----------------------------------------------------------------
  6. //
  7. //      This header contains the PXEngObject class which is the base class
  8. //    for all Paradox related objects.  All Engine type objects are derived
  9. //    from this base class.  The Engine objects are broken down into the
  10. //    following class:
  11. //
  12. //    1.  PXI.  PDOX initialization class.
  13. //
  14. //    2.  PXFamily.  PDOX family functionality (i.e. Copy, Delete).
  15. //
  16. //    3.  PXTbl.  PDOX table type functions.
  17. //
  18. //    4.  PXRec.  PDOX record type functions.
  19. //
  20. //    5.  PXField.  PDOX base class for all related field subclasses.
  21. //
  22. //    6.  PXDIS.  For displaying databases.
  23. //
  24. //    The necessary interface for inheriting Object and TStreamable is
  25. //    also provided.  You don't need the OWL to take advantage of these
  26. //    classes listed above.  You can use them for any type of interface
  27. //    you wish to construct.
  28. //
  29. // End ---------------------------------------------------------------------
  30.  
  31. // External Reference Name for this Header ---------------------------------
  32.  
  33. #ifndef PXEOBJ_HPP
  34.     #define PXEOBJ_HPP
  35.  
  36. // End ---------------------------------------------------------------------
  37.  
  38. // Interface Dependencies --------------------------------------------------
  39.  
  40. #ifndef PXENGINE_H
  41.     #include <pxengine.h>
  42. #endif // PXENGINE_H //
  43. #ifndef __OBJSTRM_H
  44.     #include <objstrm.h>
  45. #endif // __OBJSTRM_H //
  46. #ifndef PXDEF_HPP
  47.     #include "pxdef.hpp"
  48. #endif // PXDEF_HPP //
  49. #ifndef __MATH_H
  50.     #include <math.h>
  51. #endif __MATH_H
  52.  
  53. // End Interface Dependencies ----------------------------------------------
  54.  
  55.  
  56.  
  57. // class PXEngObject //
  58.  
  59. #define pxengObj    1000        /* This is the Paradox engine object
  60.                        ID */
  61.  
  62. _CLASSDEF(PXEngObject)
  63. class PXEngObject:public TStreamable,public Object
  64. {
  65. public:
  66.     // The following data structure keeps track of where an error occured
  67.     // and what handler to call to return the error string
  68.  
  69.     typedef struct EngError
  70.     {
  71.         int Origin;        /* Where did the error come from.
  72.                        Is it an engine error or a PXEWIN
  73.                        error? */
  74.                     /* Engine error member handler.
  75.                        This will return the correct
  76.                        error string depending on the
  77.                        origin of the error. */
  78.         char *(PXEngObject::* _FAR EngMem)(void);
  79.         int pxerr;        /* Error code */
  80.     }EngError;
  81. private:
  82.                     /* The following member is required
  83.                        for TStreamable compatible class
  84.                        functionality.  When the stream
  85.                        manager loads this object on the
  86.                        stream, it uses this string to
  87.                        identify the objects type.  */
  88.     virtual const Pchar streamableName() const
  89.     {
  90.         return "PXEngObject";
  91.     }
  92. protected:
  93.  
  94.     // The following data structure is used to keep track of essentual
  95.     // Engine related data between engine class types.  A pointer is
  96.     // passed to each of the object types: table, record of fields so
  97.     // these objects can share this data.
  98.  
  99.     typedef struct EngData
  100.     {
  101.         Pchar name;        /* Name of the data base */
  102.         PPXEngObject PXEObjPtr;    /* PX engine object pointer.  This
  103.                        allows other objects to reference
  104.                        a parent object */
  105.         EngError Errors;    /* Engine error pointer */
  106.         TABLEHANDLE tblHandle;    /* The table handle */
  107.         int num_fields;        /* Number of fields in table */
  108.         RECORDNUMBER num_recs;    /* Number of record in table */
  109.     }EngData;
  110.     typedef EngData _FAR *PEngData; /* For DLL compatible pointer */
  111.  
  112.     int close_status;        /* Status of closure.  If set to
  113.                        OPENED, then the destructor must
  114.                        call for proper closure.  If set
  115.                        to CLOSED, then the destructor
  116.                        must not call for closure. */
  117.     virtual Pvoid read(Ripstream);    /* Read persistant object */
  118.     virtual void write(Ropstream);    /* Write persistant object */
  119.     PXEngObject(StreamableInit)    /* Persistant object constructor */
  120.     {
  121.  
  122.     }
  123. public:
  124.     PEngData EngDataPtr;        /* Engine object data pointer */
  125.     PRECORDHANDLE recHandle;    /* Record handle */
  126.  
  127.     PXEngObject();                     /* Initialize error status */
  128.     static PTStreamable build();    /* Build persistant object */
  129.     virtual Pchar RetPXMsg()    /* Return Engine error string */
  130.     {
  131.         return PXErrMsg(EngDataPtr->Errors.pxerr);
  132.     }
  133.                     /* Return PXEWIN error message */
  134.     virtual Pchar RetPXEWINErrorMsg()
  135.     {
  136.         return EWinMsg[EngDataPtr->Errors.pxerr];
  137.     }
  138.     virtual classType isA() const
  139.     {
  140.         return pxengObj;
  141.     }
  142.     virtual Pchar nameOf() const
  143.     {
  144.         return "PXEngObject";
  145.     }
  146.     virtual hashValueType hashValue() const
  147.     {
  148.         return hashValueType(NULL);
  149.     }
  150.     virtual int isEqual( const Object&) const
  151.     {
  152.         return 1;
  153.     }
  154.     virtual void printOn( ostream _FAR & ) const
  155.     {
  156.  
  157.     }
  158.     int RetPXError()            /* Returns paradox error
  159.                            code */
  160.     {
  161.         return EngDataPtr->Errors.pxerr;
  162.     }
  163.     virtual void PXError(int org);        /* Virtual error handler */
  164.     virtual Pchar RetPXErrorMsg()
  165.     {
  166.         return (this->*EngDataPtr->Errors.EngMem)();
  167.     }
  168. };
  169.  
  170. // Description -------------------------------------------------------------
  171. //
  172. //    This class provides the necessary interface to TStreamable and Object
  173. //    classes.  All pure virtuals are define here for now.  The engine
  174. //    error codes are saved here also as well as the parent object pointer
  175. //
  176. // End ---------------------------------------------------------------------
  177.  
  178. // Define inserters and extractors for persistant objects:
  179.  
  180. inline Ripstream operator >> (Ripstream is,RPXEngObject cl)
  181.     {return is >> (RTStreamable)cl;}
  182.  
  183. inline Ripstream operator >> (Ripstream is,RPPXEngObject cl)
  184.     {return is >> (RPvoid)cl;}
  185.  
  186. inline Ropstream operator << (Ropstream os,RPXEngObject cl)
  187.     {return os << (RTStreamable)cl;}
  188.  
  189. inline Ropstream operator << (Ropstream os,PPXEngObject cl)
  190.     {return os << (PTStreamable)cl;}
  191.  
  192. #endif  // PXEOBJ_HPP //
  193.  
  194.